#coding:utf-8
# from homeapp.models import TTest
from homeapp.models import RTLog_TNote
# import uuid

class rtlog_tnote_dal():

    # selectjoinmodelbyLogId
    @staticmethod
    def selectjoinmodelbyLogId(guid):

        sql = "select homeapp_rtlog_tnote.guid, homeapp_rtlog_tnote.guid rguid, Log_Guid , Note_Guid , `order`, homeapp_tnote.guid , homeapp_tnote.guid tguid, Account_Guid , NoteDateTime , Path , Text , NoteType_Guid  from homeapp_rtlog_tnote join homeapp_tnote on homeapp_rtlog_tnote.Note_Guid = homeapp_tnote.guid where homeapp_rtlog_tnote.Log_Guid = %s"
        paraint1 = str(guid)
        raw_querySet = RTLog_TNote.objects.raw(sql, [ paraint1 ])
        return raw_querySet

    """
    @staticmethod
    def selectlog():

        # 得到 tlog 列表
        sql = "select * from homeapp_tlog;"
        objects = TLog.objects.raw(sql)

        return objects

    @staticmethod
    def selectbyguids(guids):

        # 得到guids的个数
        guidcount = len(guids)
        zo = 0

        # 拼接sql字符串
        strsql = "select homeapp_tnote.guid, homeapp_tnote.guid as mguid, Path, homeapp_tnotetype.guid, homeapp_tnotetype.guid as tguid, Text, TypeName from homeapp_tnote join homeapp_tnotetype on homeapp_tnote.NoteType_Guid = homeapp_tnotetype.guid where homeapp_tnote.guid in ("

        for guid in guids:
            if zo == guidcount - 1:
                strsql += "'" + guid + "')"
                zo += 1
            else:
                strsql += "'" + guid + "',"
                zo += 1

        objs = TLog.objects.raw(strsql)

        return objs
    """

